"""KnowledgeMatchSystem URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/3.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include, re_path
from django.conf.urls import url
# 导入静态文件解决方法
# from django.views.static import serve
# 导入drf
from rest_framework.documentation import include_docs_urls
from rest_framework.routers import DefaultRouter
# 导入静态文件配置
# from django.views import static
from django.views import static as views_static
from django.conf import settings
from django.conf.urls.static import static as urls_static

# 导入users应用的views.py文件
from apps.users import views as users_views
# 导入resources应用的views.py文件
from apps.resources import views as resources_views
# 导入works应用的views.py文件
from apps.works import views as works_views

# 通过Router配置users应用路由
router = DefaultRouter()

# 注册用户应用下用户信息视图集
router.register('users/user', users_views.UserInfoViewset, basename='users-user')
# 注册资源应用下车辆信息视图集
router.register('resources/car', resources_views.CarInfoViewset, basename='resources-car')
# 注册资源应用下固定站点信息视图集
router.register('resources/fixed-station', resources_views.CarInfoViewset, basename='resources-fixed-station')
# 注册资源应用下提醒信息视图集
router.register('resources/tips', resources_views.CarInfoViewset, basename='resources-tips')
# 注册工作应用下提醒信息视图集
router.register('works/mobile-station', works_views.MobileStationInfoViewset, basename='works-mobile-station')
# 注册工作应用下旅客类型信息视图集
router.register('works/tourist-type', works_views.TouristTypeInfoViewset, basename='works-tourist-type')
# 注册工作应用下旅客乘车信息视图集
router.register('works/tourist-ride', works_views.TouristRideInfoViewset, basename='works-tourist-ride')

from django.contrib import admin
from django.urls import path
from psbs.settings import DOCS_NAME

urlpatterns = [
    path('admin/', admin.site.urls),
    # DRF自动生成文档
    path('docs/', include_docs_urls(title=f'{DOCS_NAME}', description=f'{DOCS_NAME}')),
    path('api/', include(router.urls)),
    # path('login/', obtain_jwt_token),
    # 支付宝
    # url(r'^alipay/return/', payment_views.AlipayView.as_view(), name="alipay-return"),
    # 配置访问静态文件的路径
    url(r'^static/(?P<path>.*)$', views_static.serve, {'document_root': settings.STATIC_ROOT}, name='static'),
    # 配置访问媒体文件的路径
    url(r'^media/(?P<path>.*)$', views_static.serve, {'document_root': settings.MEDIA_ROOT}, name='media'),
]
